package cn.bytepulse.web.auth.controller;

import cn.bytepulse.annotation.Anonymous;
import cn.bytepulse.annotation.Log;
import cn.bytepulse.pojo.AjaxResult;
import cn.bytepulse.web.auth.params.LoginParam;
import cn.bytepulse.web.auth.service.AuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 认证
 *
 * @author jiejiebiezheyang
 * @since 2024-03-03 11:00
 */
@Tag(name = "管理-登录认证")
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AuthController {

    private final AuthService authService;

    @PostMapping("/login")
    @Operation(summary = "登录")
    @Log(value = "管理-用户登录", persist = true)
    @Anonymous
    public AjaxResult login(@RequestBody @Validated LoginParam loginParam) {
        return authService.login(loginParam);
    }

    @GetMapping("/connect")
    @Operation(summary = "登录状态测试")
    @Log(value = "管理-登录状态测试")
    public AjaxResult ping() {
        return authService.ping();
    }
}
